package com.jiantong.work.impl.manager;

import com.jiantong.work.impl.dao.CertNumberDao;
import com.jiantong.work.model.CertNumber;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

/**
 * Created by mz03 on 2017/5/9.
 */
@Component
public class CertNumberManager {

    private final CertNumberDao certNumberDao;

    public CertNumberManager(CertNumberDao certNumberDao) {
        this.certNumberDao = certNumberDao;
    }

    /**

     */
    @Transactional
    public CertNumber findCertNumberAndUpdateStatus(){

        CertNumber certNumber = certNumberDao.randomFind();
        //如果certNumber为null 则号段用完 提示:
        CertNumber certNumber1 = certNumber;
        certNumber1.setCertStatus(0);
        certNumberDao.update(certNumber1);


        return certNumber;
    }

}
